﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace VTLive.Models
{
    public class SuggestionRepository
    {
        VTliveDataContext db = new VTliveDataContext();

        public IQueryable<Suggestion> GetAllSuggestions()
        {
            return db.Suggestions;
        }
        
        public IQueryable<Suggestion> GetSuggestionsForStation(int StationID)
        {
            return (from Suggestion in db.Suggestions
                   where Suggestion.StationID == StationID
                   select Suggestion);
        }

        public void Add(Suggestion MySuggestion)
        {
            db.Suggestions.InsertOnSubmit(MySuggestion);
        }

        public void Delete(Suggestion MySuggestion)
        {
            db.Suggestions.DeleteOnSubmit(MySuggestion);
        }

        public void Save()
        {
            db.SubmitChanges();
        }

        internal Suggestion GetSuggestion(int suggestionid)
        {
            return (from s in db.Suggestions where s.ID == suggestionid select s).SingleOrDefault();
        }
    }
}
